﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MethodWorx.CMS.Plugins
{
    public class EmbeddedViewResult : ViewResult
    {
        public EmbeddedViewResult(AssemblyResourceReference resource)
            : this(resource, null)
        {
        }

        public EmbeddedViewResult(AssemblyResourceReference resource, object model) 
            : this(resource, null, model)
        {
        }

        public EmbeddedViewResult(Controller controller, AssemblyResourceReference resource, object model)
            : this(resource, null, model)
        {
            this.ViewData = controller.ViewData;
            //  ok, also output the style
            this.ViewName = "Embedded";
            this.ViewData["__EmbeddedViewName"] = resource.Name;
            this.ViewData.Model = model;
        }

        public EmbeddedViewResult(AssemblyResourceReference resource, ViewDataDictionary viewData, object model)
        {
            if (viewData != null)
                this.ViewData = viewData;
            //
            //  ok, also output the style
            this.ViewName = "Embedded";
            this.ViewData["__EmbeddedViewName"] = resource.Name;            
            this.ViewData.Model = model;
        }
    }
}
